home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak 74
/
Volume 74 My Disc - Damaged.iso
/
Games
/
remote_control.swf
/
scripts
/
frame_1
/
DoAction.as
Wrap
Text File
|
2008-08-08
|
11KB
|
522 lines
function changeChannel()
{
if(whoHasRemote == "player")
{
if(altShows1)
{
Television.gotoAndStop(playerSelected + "_alt1");
}
else if(altShows2)
{
Television.gotoAndStop(playerSelected + "_alt2");
}
else
{
Television.gotoAndStop(playerSelected);
}
}
else if(whoHasRemote == "opponent")
{
if(altShows1)
{
if(playerSelected == "brother")
{
Television.gotoAndStop("sister_alt1");
}
else
{
Television.gotoAndStop("brother_alt1");
}
}
else if(altShows2)
{
if(playerSelected == "brother")
{
Television.gotoAndStop("sister_alt2");
}
else
{
Television.gotoAndStop("brother_alt2");
}
}
else if(playerSelected == "brother")
{
Television.gotoAndStop("sister");
}
else
{
Television.gotoAndStop("brother");
}
}
}
function clearScreen()
{
if(lateNite == true)
{
removeMovieClip("LateNite");
}
removeMovieClip("Interface");
removeMovieClip("Player");
removeMovieClip("Opponent");
removeMovieClip("EndTable1");
removeMovieClip("EndTable2");
removeMovieClip("CoffeeTable");
removeMovieClip("Ottoman1");
removeMovieClip("Ottoman2");
removeMovieClip("Sofa");
}
function levelUp()
{
level++;
playerMoveSpeed++;
playerFreezeCount += 5;
opponentMoveSpeed++;
opponentFreezeCount -= 5;
}
function chooseOpponentDir()
{
if(whoHasRemote == "player")
{
var _loc2_ = Player._x - Opponent._x;
var _loc3_ = Player._y - Opponent._y;
}
else if(whoHasRemote == "opponent")
{
_loc2_ = Opponent._x - Player._x;
_loc3_ = Opponent._y - Player._y;
}
var _loc1_ = [];
_loc1_.push(checkMazeHit(Opponent._x,Opponent._y - 50));
_loc1_.push(checkMazeHit(Opponent._x,Opponent._y + 50));
_loc1_.push(checkMazeHit(Opponent._x - 50,Opponent._y));
_loc1_.push(checkMazeHit(Opponent._x + 50,Opponent._y));
if(_loc2_ < 0 && _loc3_ < 0)
{
if(randInt(1,2) == 1)
{
if(_loc1_[0] == false)
{
dir = "up";
}
else
{
dir = "left";
}
}
else
{
dir = "left";
}
}
else if(_loc2_ == 0 && _loc3_ < 0)
{
if(_loc1_[0] == false)
{
dir = "up";
}
else if(randInt(1,2) == 1)
{
dir = "left";
}
else
{
dir = "right";
}
}
else if(_loc2_ > 0 && _loc3_ < 0)
{
if(randInt(1,2) == 1)
{
if(_loc1_[0] == false)
{
dir = "up";
}
else
{
dir = "right";
}
}
else
{
dir = "right";
}
}
else if(_loc2_ > 0 && _loc3_ == 0)
{
if(_loc1_[3] == false)
{
dir = "right";
}
else if(randInt(1,2) == 1)
{
dir = "up";
}
else
{
dir = "down";
}
}
else if(_loc2_ > 0 && _loc3_ > 0)
{
if(randInt(1,2) == 1)
{
if(_loc1_[1] == false)
{
dir = "down";
}
else
{
dir = "right";
}
}
else
{
dir = "right";
}
}
else if(_loc2_ == 0 && _loc3_ > 0)
{
if(_loc1_[1] == false)
{
dir = "down";
}
else if(randInt(1,2) == 1)
{
dir = "left";
}
else
{
dir = "right";
}
}
else if(_loc2_ < 0 && _loc3_ > 0)
{
if(randInt(1,2) == 1)
{
if(_loc1_[1] == false)
{
dir = "down";
}
else
{
dir = "left";
}
}
else
{
dir = "left";
}
}
else if(_loc2_ < 0 && _loc3_ == 0)
{
if(_loc1_[2] == false)
{
dir = "left";
}
else if(randInt(1,2) == 1)
{
dir = "up";
}
else
{
dir = "down";
}
}
else if(_loc2_ == 0 && _loc2_ == 0)
{
var _loc4_ = randInt(1,4);
if(_loc4_ == 1)
{
dir = "up";
}
if(_loc4_ == 2)
{
dir = "down";
}
if(_loc4_ == 3)
{
dir = "left";
}
if(_loc4_ == 4)
{
dir = "right";
}
}
return dir;
}
function moveAvatar(theClip, theDir)
{
var _loc6_ = Math.floor(theClip._y / 50) - 1;
var _loc5_ = Math.floor(theClip._x / 50);
if(theDir == "up")
{
destX = theClip._x;
destY = theClip._y - theClip.moveSpeed;
edgeX = destX;
edgeY = destY - 49;
}
else if(theDir == "down")
{
destX = theClip._x;
destY = theClip._y + theClip.moveSpeed;
edgeX = destX;
edgeY = destY - 1;
}
else if(theDir == "left")
{
destX = theClip._x - theClip.moveSpeed;
destY = theClip._y;
edgeX = destX - 24;
edgeY = destY - 1;
}
else if(theDir == "right")
{
destX = theClip._x + theClip.moveSpeed;
destY = theClip._y;
edgeX = destX + 24;
edgeY = destY - 1;
}
var _loc4_ = Math.floor(edgeY / 50);
var _loc3_ = Math.floor(edgeX / 50);
if(!checkMazeHit(edgeX,edgeY,theDir))
{
theClip._x = destX;
theClip._y = destY;
theClip.moveDir = theDir;
theClip.gotoAndStop(theDir);
}
else
{
if(theDir == "up")
{
theClip._y = (_loc4_ + 1) * 50 + 50;
}
else if(theDir == "down")
{
theClip._y = _loc4_ * 50;
}
else if(theDir == "left")
{
theClip._x = (_loc3_ + (_loc5_ - _loc3_)) * 50 + 25;
}
else if(theDir == "right")
{
theClip._x = _loc3_ * 50 - 25;
}
theClip.moveDir = null;
theClip.gotoAndStop("stopped");
}
}
function checkMazeHit(posX, posY, theDir)
{
if(theDir == "up")
{
if(MazeWalls.hitTest(posX,posY,true))
{
return true;
}
return false;
}
if(theDir == "down")
{
if(MazeWalls.hitTest(posX,posY,true))
{
return true;
}
return false;
}
if(theDir == "left")
{
if(MazeWalls.hitTest(posX,posY,true))
{
return true;
}
return false;
}
if(theDir == "right")
{
if(MazeWalls.hitTest(posX,posY,true))
{
return true;
}
return false;
}
if(theDir == undefined)
{
if(!MazeWalls.hitTest(posX,posY - 49,true))
{
if(!MazeWalls.hitTest(posX,posY - 49,true))
{
if(!MazeWalls.hitTest(posX,posY - 1,true))
{
if(!MazeWalls.hitTest(posX,posY - 1,true))
{
return false;
}
return true;
}
return true;
}
return true;
}
return true;
}
}
function decrementTimer()
{
if(gameInPlay)
{
if(secondsLeft == 0)
{
if(minutesLeft == 0)
{
clearInterval(timerCode);
var _loc1_ = playerMinutes * 60 + playerSeconds;
var _loc2_ = opponentMinutes * 60 + opponentSeconds;
if(_loc1_ > _loc2_)
{
gotoAndStop("WinLevel");
play();
}
else
{
gotoAndStop("GameOver");
play();
}
}
else
{
secondsLeft = 59;
minutesLeft--;
awardPoint();
}
}
else
{
secondsLeft--;
awardPoint();
}
}
}
function awardPoint()
{
if(whoHasRemote == "player")
{
if(playerSeconds == 59)
{
playerSeconds = 0;
playerMinutes++;
}
else
{
playerSeconds++;
}
}
else if(whoHasRemote == "opponent")
{
if(opponentSeconds == 59)
{
opponentSeconds = 0;
opponentMinutes++;
}
else
{
opponentSeconds++;
}
}
}
function setTimerDigits(theMins, theSecs, theClip)
{
minutesText = String(theMins);
secondsText = String(theSecs);
if(minutesText.length < 2)
{
theClip.mins1 = "";
theClip.mins2 = minutesText;
}
else
{
theClip.mins1 = minutesText.substr(0,1);
theClip.mins2 = minutesText.substr(1,1);
}
if(secondsText.length < 2)
{
theClip.secs1 = "0";
theClip.secs2 = secondsText;
}
else
{
theClip.secs1 = secondsText.substr(0,1);
theClip.secs2 = secondsText.substr(1,1);
}
}
function randInt(num0, num1)
{
if(arguments.length == 1)
{
return Math.round(Math.random() * num0);
}
return Math.round(Math.random() * Math.abs(num0 - num1)) + num0;
}
function shuffle(theArray)
{
i = 0;
while(i < theArray.length - 1)
{
var _loc2_ = Math.round(Math.random() * i);
var _loc3_ = theArray[i];
theArray[i] = theArray[_loc2_];
theArray[_loc2_] = _loc3_;
i++;
}
return theArray;
}
getURL("FSCommand:allowscale",false);
var playerSelected = "";
clearScreen();
stop();
funcHITBOX = function(arString)
{
trace(arString);
getURL("javascript:_hbPageView (\'/gamepad/play/games/RemoteControlRuckus/game/" + arString + "\', \'/\')","");
};
keyHandler = new Object();
keyHandler.onKeyDown = function()
{
if(Key.getCode() == 38)
{
upKeyDown = true;
}
if(Key.getCode() == 40)
{
downKeyDown = true;
}
if(Key.getCode() == 37)
{
leftKeyDown = true;
}
if(Key.getCode() == 39)
{
rightKeyDown = true;
}
};
keyHandler.onKeyUp = function()
{
if(Key.getCode() == 38)
{
upKeyDown = false;
}
if(Key.getCode() == 40)
{
downKeyDown = false;
}
if(Key.getCode() == 37)
{
leftKeyDown = false;
}
if(Key.getCode() == 39)
{
rightKeyDown = false;
}
};